package com.open.spring.common.servlet;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

/**
 * 登陆拦截
 * @author kinter
 *
 */
public class LoginCheckInterceptor implements HandlerInterceptor{
	@SuppressWarnings("serial")
	private static final List<String> unCkeckList = new ArrayList<String>(){
		{
			add("/web/login");
			add("/web/index");
			add("/app/index");
			add("/app/login");
			add("/app/game/info");
			add("/web/auth");
			add("/app/auth");
		}
	};
	@Override
	public boolean preHandle(HttpServletRequest request,
			HttpServletResponse response, Object handler) throws Exception {
		/**
		 * 添加登陆校验逻辑
		 */
		String uri = request.getPathInfo();
		if(unCkeckList.contains(uri)||1==uri.length()){
			return true;
		}else{
			
				
				
			return true;	
			
		}
	}

	@Override
	public void postHandle(HttpServletRequest request,
			HttpServletResponse response, Object handler,
			ModelAndView modelAndView) throws Exception {
		
	}

	@Override
	public void afterCompletion(HttpServletRequest request,
			HttpServletResponse response, Object handler, Exception ex)
			throws Exception {
		
		
	}

}
